<?php
/**
 *      [迷你云] (C)2009-2012 南京恒为网络科技.
 *   软件仅供研究与学习使用，如需商用，请访问www.miniyun.cn获得授权
 * 
 */
?>
<?php

class OnlineDevice extends CMiniyunModel
{
	
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	
	public function tableName()
	{
		return Yii::app()->params['tablePrefix'].'online_devices';
	}


	public function relations()
	{
			
		return array(
		);
	}

	
	public function attributeLabels()
	{
		return array(

		);
	}
    public function getOnlineCount(){
    	return $this->count("(now()-updated_at)<=300");
    }
    public function deviceLogout(){
    	 $dbCommand = Yii::app()->db->createCommand("update `".Yii::app()->params['tablePrefix']."online_devices` set updated_at=SUBTIME(updated_at,'0 0:6:0.0') where id=".$this->id);
		 $dbCommand->query(); 
    }
}